<?php 

class Project extends CI_Controller {

	function __construct(){
		parent::__construct();
		$this->load->model('project_m');
		if($this->session->userdata('username') == false){
			redirect('login');
		}
	}
	function add(){
		$data = array(
			'title' => 'Project Management',
		);
		
		$this->load->view('account/includes/header',$data);
		$this->load->view('account/project/add_project');
		$this->load->view('account/includes/footer');
	}
	function addnew(){

			$res = $this->project_m->addnew_project();
			if($res) redirect('accounts'); 

	}
	function get_project_view(){
		
		echo $this->project_m->datatables_pr();
		
	}
	function view(){
			
		$data = array(
			'title' => 'Edit Project',
		);
		
		$this->load->view('account/includes/header',$data);
		$this->load->view('account/project/project_view');
		$this->load->view('account/includes/footer');
			
			
	}
	function edit(){


		$row = $this->project_m->get_project();
		
		if($row == false) redirect('project/view');
		
		$data = array(
			'title' => 'Edit Project',
			'row' => $row
		);
		
		$this->load->view('account/includes/header',$data);
		$this->load->view('account/project/edit_project');
		$this->load->view('account/includes/footer');
		
	}
	function save_edit(){
		$res = $this->project_m->save_edit();
		if($res) redirect('project/view'); 
	}
}// end class projects..